<template>
    <div>
        <van-nav-bar
                title="用户登陆"
                :z-index="nav_z_index"
        />
        <div class="wai">
            <van-cell-group class="nei">
                <van-field
                        v-model="username"
                        label="用户名"
                        placeholder="请输入用户名"
                />
                <van-field
                        v-model="password"
                        type="password"
                        label="密码"
                        placeholder="请输入密码"
                />
                <van-button
                        class="submit"
                        type="primary"
                        @click="onSubmit"
                >
                    登陆
                </van-button>
            </van-cell-group>
        </div>
    </div>
</template>

<script>
    import {NavBar, Cell, CellGroup, Field, Toast, Button} from 'vant';
    import { router } from '@/router';
    export default {
        props: ['id', 'newsletterPopup'],
        components: {
            [NavBar.name]: NavBar,
            [Cell.name]: Cell,
            [CellGroup.name]: CellGroup,
            [Field.name]: Field,
            [Toast.name]: Toast,
            [Button.name]: Button,
        },

        data() {
            return {
                nav_z_index: 900,
                username: '',
                password: '',
            };
        },

        beforeCreate: function () {
            console.log('beforeCreate1')
        },
        created: function () {
            console.log('created1')
        },
        beforeMount: function () {
            console.log('beforeMount1')
        },
        mounted: function () {
            console.log('mounted1')
        },
        beforeUpdate: function () {
            console.log('beforeUpdate1')
        },
        updated: function () {
            console.log('updated1')
        },
        activated: function () {
            console.log('zzzzzzzzzzzz', this.id);
            console.log('zzzzzzzzzzzz', this.newsletterPopup);
            // let routes = this.$router.options.routes;
            console.log([this.$route.params, this.$route]);
            // console.log(this.$router);
            // console.log('activated1')
        },
        deactivated: function () {
            console.log('deactivated1')
        },
        beforeDestroy: function () {
            console.log('beforeDestroy1')
        },
        destroyed: function () {
            console.log('destroyed1')
        },
        errorCaptured: function () {
            console.log('errorCaptured1')
        },

        computed: {
            // difference_quantity() {
            //     let xxxx5 = 0;
            //     let list = this.list;
            //     list.forEach(item => {
            //         if (item.key === 'xxxx5') {
            //             xxxx5 = item.value
            //         }
            //     });
            //     let oitm_weight = this.oitm_weight;
            //     return xxxx5 - oitm_weight;
            // },
        },

        methods: {
            onSubmit() {
                Toast('点击了登陆页面');
                router.push({ path: '/' });
            },
        }
    };
</script>

<style scoped lang="less">
    .wai {
        display: flex;
    }

    .nei {
        margin: 50% auto;
    }

    .submit {
        width: 100%;
    }
</style>
